#include "ADUBasin.h"


Basin* Basin::CreateBasin(){
	Basin* basin = new Basin();

    if (basin && basin->initWithFile(mPath)) {
    	basin->autorelease();
        return basin;
    }

    CC_SAFE_DELETE(basin);

	return NULL;
}

void Basin::Clean(){
    GameManager::getInstance()->mWater->RemoveBody(mBody);
    GameManager::getInstance()->mWorld->DestroyBody(mBody);
    
}

void Basin::integrateBox2D() {
	Vec2 pos = this->getPosition();
	b2BodyDef bodyDef;
	bodyDef.type = b2_dynamicBody;
	bodyDef.userData = this;

	bodyDef.position.Set(pos.x/PTM_RATIO, pos.y/PTM_RATIO);
	bodyDef.fixedRotation = true;
	mBody = GameManager::getInstance()->mWorld->CreateBody(&bodyDef);
    mBody->SetTag(1);
    mBody->SetLinearDamping(0.7);
    // add the fixture definitions to the body
    GB2ShapeCache *sc = GB2ShapeCache::sharedGB2ShapeCache();
    sc->addFixturesToBody(mBody, FIXTURE_BASIN, DENSITY_BASIN, FRICTION_BASIN, RESTITUTION_BASIN);
    this->setAnchorPoint(sc->anchorPointForShape(FIXTURE_BASIN));	
}